class ReciteScene extends Scene{
    private back:eui.Image;//返回
    private collect:eui.ToggleButton;//收藏按钮
    private menu:eui.Image;//菜单按钮
    private wenhao:eui.Image;//问号
    private click:eui.Image;//点击屏幕显示释义
    private play1:eui.Image;//听单词1
    private play2:eui.Image;//听单词2
    private thumb2:eui.Image;
    private know:eui.Button;//认识按钮
    private unknow:eui.Button;//不认识按钮
    private wanfa:eui.Image;//玩法介绍
    private baocuo:eui.Image;//单词报错
    private huile:eui.Image;//我真的会了
    private shiyi:eui.Label;//释义
    private word:eui.Label;//单词的label
    private pron1:eui.Label;//英式音标
    private pron2:eui.Label;//美式音标
    private exa:eui.Label;//经典例句字样
    private liju:eui.Label;//两个例句的标签
    private thumb1:eui.Image;
    private danciyisi:eui.Label;
    private time:egret.Timer;
    private hr:egret.HttpRequest;
    public static obj:any[];
    private menu_Group:eui.Group;
    private i:any;
    private sound:egret.Sound;
    public constructor(){
        super();
        this.i=0;//单词下标
}
    public onSkinLoaded(){
    //进入单词页面就可以看到第一个单词的相关信息
      this.word.text=CET4Scene.obj[this.i].english;
      this.pron1.text="英"+CET4Scene.obj[this.i].e_phon;
      this.pron2.text="美"+CET4Scene.obj[this.i].a_phon;
      this.danciyisi.text=CET4Scene.obj[this.i].meaning;
      this.liju.text=CET4Scene.obj[this.i].example1+"\n\n"+CET4Scene.obj[this.i].example2;


        this.back.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onclick,this);//返回
        this.click.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onclick_1,this);//点击屏幕显示释义
        this.know.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onclick_2,this);//认识按钮
        this.wenhao.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onclick_3,this);//问好
        this.menu.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onclick_4,this);//菜单
        this.play1.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onclick_5,this);//第一个听单词按钮
        this.play2.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onclick_6,this);//第二个听力播放键
        this.time=new egret.Timer(1000,0);//时间进度条
        this.time.addEventListener(egret.TimerEvent.TIMER,this.timerHandler,this);
        this.time.start();
       //收藏按钮
       this.collect.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onclick_7,this);
       this.thumb1.width=0;//第一个进度条的初始长度。
       this.thumb2.width=0;
    }
   private onclick(){//点击返回,将跳转到任务界面
      SceneManager.instance.removeScene(this);
    }
    private onclick_1(){//点击屏幕显示释义
        this.click.visible=false;//点击释义的图片隐藏
        this.shiyi.visible=true;//内容可见
        this.exa.visible=true;
        this.danciyisi.visible=true;
        this.liju.visible=true;//
    }
    private onclick_2(){//点击认识按钮，下一个单词，word的text
      if(this.thumb1.width==210){
          //当进度条满了时，做出处理。根据实际要求修改代码 
      }
      if(this.click.visible==false){
        this.shiyi.visible=false;
        this.click.visible=true;
        this.exa.visible=false;
        this.danciyisi.visible=false
        this.liju.visible=false;
        this.click.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onclick_1,this);
      }
      this.i++;
      this.word.text=CET4Scene.obj[this.i].english;//此处text是下一个单词，---------------------从数据库获取
      this.pron1.text="英"+CET4Scene.obj[this.i].e_phon;//---------------------从数据库获取
      this.pron2.text="美"+CET4Scene.obj[this.i].a_phon;//---------------------从数据库获取
      this.danciyisi.text=CET4Scene.obj[this.i].meaning;//---------------------从数据库获取
      this.liju.text=CET4Scene.obj[this.i].example1+"\n"+CET4Scene.obj[this.i].example2;//---------------------从数据库获取
      //this.pro1.value+=2;//进度条的最大值将取决于计划中
      //点击认识，进度条长度变化
      this.thumb1.scale9Grid=new egret.Rectangle(10,0,45,14);//47表示的是原图A5部分的宽，14表示原图A5部分的高；
      this.thumb1.width+=210/20;//增加数值将取决于单词任务的个数。
      this.thumb1.height=14;          
    }
private onclick_3(){//点击问号
    if(this.menu_Group.visible==true){
        this.menu_Group.visible=false;
    }
    if(this.wanfa.visible==true){
        this.wanfa.visible=false;
    }
    else{
        this.wanfa.visible=true;
    }
    
}
private onclick_4(){//点击菜单
if(this.wanfa.visible==true){
    this.wanfa.visible=false;
}
if(this.menu_Group.visible==true){
   this.menu_Group.visible=false;
}
else{
      this.menu_Group.visible=true;
}
}
private onclick_5(){//第一个听力播放键
    //alert("播放英式英语");
    this.sound= new egret.Sound();
   this.sound.addEventListener(egret.Event.COMPLETE, function loadOver(event:egret.Event) {
      this.sound.play(0,1);
  }, this);
  this.sound.addEventListener(egret.IOErrorEvent.IO_ERROR, function loadError(event:egret.IOErrorEvent) {
      console.log("loaded error!");
  }, this);
 
    this.sound.load("http://dict.youdao.com/dictvoice?type=1&audio="+CET4Scene.obj[this.i].english);
}
private onclick_6(){//第二个听力播放键
    //alert("播放美式英语");
     this.sound= new egret.Sound();
   this.sound.addEventListener(egret.Event.COMPLETE, function loadOver(event:egret.Event) {
      this.sound.play(0,1);
  }, this);
  this.sound.addEventListener(egret.IOErrorEvent.IO_ERROR, function loadError(event:egret.IOErrorEvent) {
      console.log("loaded error!");
  }, this);
 
    this.sound.load("http://dict.youdao.com/dictvoice?type=2&audio="+CET4Scene.obj[this.i].english);
}
private onclick_7(){//收藏按钮，是否要存入数据库，判断是取消还是收藏，收藏即存入数据库，取消收藏则从数据库删除

}
private timerHandler():void{//时间进度条
    if(this.thumb2.width==210){
        //超出时间做出处理，根据实际情况修改内容
    }
    this.thumb2.scale9Grid=new egret.Rectangle(10,0,45,14);
    this.thumb2.width+=210/30;//2010示进度条外框的长度，100表示时间为100s
    this.thumb2.height=14;

}

}